import { OffLightState, WeakLightState, StrongLightState } from './state.js';

export default class Light {
    constructor() {
        this.offLightState = new OffLightState(this);
        this.weakLightState = new WeakLightState(this);
        this.strongLightState = new StrongLightState(this);
        this.button = null;
    }

    init() {
        let button = document.createElement('button');
        this.button = document.body.appendChild(button);
        this.button.innerHTML = '开关';
        this.currState = this.offLightState; // 设置默认初始状态
        
        this.button.onclick = () => {
            this.currState.buttonWasPressed();
        }
    }

    setState(state) {
        this.currState = state;
    }
}